function [s_jt, share]  = f_share_mktwide( ...
    theta,      ...
    Pi,         ...
    rho,        ...
    x_jt,       ...
    xnonlin_jt, ...
    xi_jt,      ...
    dfull_jt,    ...
    in_samp_mrkwide ...
)

delta   = pagemtimes(x_jt, reshape(theta, [], 1, 1)) + xi_jt;
mu      = pagemtimes(xnonlin_jt, reshape(Pi, [], 1, 1)) .* dfull_jt;
dmu   = exp((delta + mu) / (1 - rho)).*in_samp_mrkwide;

I_i1rt  = (1 - rho) * log(sum(dmu));
sgroup  = exp(I_i1rt) ./ (1 + exp(I_i1rt));
scond   = dmu ./ sum(dmu);
share   = scond .* sgroup;
s_jt    = mean(share, 2);
